package com.offcn.search.controller;

import com.offcn.entity.Result;
import com.offcn.entity.StatusCode;
import com.offcn.search.service.SkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author: zola
 * @Date: 2021/9/11 - 09 - 11 - 23:29
 * @Description: com.offcn.search.controller
 * @Version: 1.0
 */
@RestController
@RequestMapping("/sku")
public class SkuController {

    @Autowired
    private SkuService skuService;
    // 导入
    @GetMapping("/import")
    public Result skuImport(){
        try {
            skuService.importSku();
            return new Result(true, StatusCode.OK,"导入成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, StatusCode.ERROR,"导入失败");
        }
    }

    @PostMapping
    public Map search(@RequestBody(required = false) Map searchMap){
        return skuService.search(searchMap);
    }
}
